

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main" />
    <g:javascript library="prototype"/>
    <g:javascript library="scriptaculous"/>

    <title>Message List</title>
  </head>
  <body>
    <div class="nav">
      <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>
    </div>
    <div class="body">
      <h1>Message List</h1>
      <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
      </g:if>
      <div id="msglist">
      <g:render template ="message_list" ></g:render>
      </div>
      <div >
        <g:formRemote name="createMessage"  url="[controller:'message',action:'save']" update="msglist">
          <div>
            <span>昵称:</span><span><input type="text" name="username" id="username" style="width:180px;" maxlength="80" value="${request.remoteAddr}"></span>
          </div>
          <textarea rows="35" cols="40" name="content" style="width:600px;height:50px;"></textarea>
          <div>
            <input class="save" type="submit" value="发送" />
            <span id="spinner" style="display:none;">
              <img src="${createLinkTo(dir:'images',file:'spinner.gif')}" alt="Spinner" />
            </span>
          </div>
        </g:formRemote>
      </div>
    </div>
    <script type="text/javascript">
      var url="${createLink(controller:'message',action:'msgList')}";
      new Ajax.PeriodicalUpdater('msglist',url, {   method: 'get', frequency:2, decay: 1 });
     /*/ new PeriodicalExecuter(function(pe){
        if (!confirm('Want me to annoy you again later?'))
          pe.stop();
      }, 2);*/
    </script>
  </body>
</html>
